package com.flyan.game.motafx.core.algorithm;

import lombok.Getter;

/**
 * 祭坛交易算法
 *
 * @author flyan
 * @version 1.0
 * @email flyan_by_chenu@sina.com
 * @since 2025/2/10
 */
@Getter
public class AlterTransactionAlgorithm {

    /**
     * 首次购买所需金额
     */
    private final int firstAmount;

    /**
     * 最后一次交易金额
     */
    private int lastTransactionAmount;

    /**
     * 已交易次数
     */
    private int numberOfTransaction;

    public AlterTransactionAlgorithm(int firstAmount) {
        this.firstAmount = this.lastTransactionAmount = firstAmount;
    }

    /**
     * 获取当前交易所需金额
     *
     * @return 金额
     */
    public int transactionAmount() {
        return lastTransactionAmount + firstAmount * numberOfTransaction;
    }

    /**
     * 完成交易
     *
     * @return 交易金额
     */
    public int completeTransaction() {
        lastTransactionAmount = transactionAmount();
        numberOfTransaction += 1;
        return lastTransactionAmount;
    }

}
